package com.correction.service;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.correction.classes.NoteExercice;
import com.correction.utils.HibernateUtil;

public class NoteDao {

	public static NoteExercice saveNote(NoteExercice note) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = null;
		//comment
		try {
			transaction = session.beginTransaction();
			session.saveOrUpdate(note);
			transaction.commit();
		} catch (HibernateException e) {
			transaction.rollback();
			e.printStackTrace();
		} finally {
			session.close();
		}
		return note;

	}
}
